package day7;

import java.util.ArrayList;
import java.util.List;

class Acticle{
    private int id;

    private String title;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Acticle(int id, String title) {
        this.id = id;
        this.title = title;
    }

    @Override
    public String toString() {
        return "Acticle{" +
                "id=" + id +
                ", title='" + title + '\'' +
                '}';
    }
}

public class Demo2 {

    public static void main(String[] args) {
        List QQ = new ArrayList();
        QQ.add(new Acticle(1, "南京新增2个高风险地区，现有4个高风险和25个中风险地区"));
        QQ.add(new Acticle(2, "奥运跳水-男子双人十米台曹缘/陈艾森遗憾摘银 戴利组合夺冠"));
        QQ.add(new Acticle(3, "中方如何看待美方为中美关系“设护栏”提议？外交部回应"));
        QQ.add(new Acticle(4, "河南新乡医学院一附院告急 大量患者等转移 急需发电机皮划艇"));
        QQ.add(new Acticle(5, "七部门发文：外卖送餐员正常劳动所得不低于当地最低工资标准"));

        for (int i = 0; i < QQ.size(); i++){
            Acticle a = (Acticle)QQ.get(i);
            if (a.getTitle().toCharArray().length > 15){
                String title ="";
//                for (int j = 0; j < 10; j++){
//                    title = title + (a.getTitle().toCharArray()[j]);
//                }
//
//                title = title + "...";
                title = title + a.getTitle().substring(0, 10) + "...";
                a.setTitle(title);
            }
            System.out.println(a.getTitle());
        }
    }
}
